package com.ruoyi.equ.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.equ.domain.EquColRetuDetail;
import com.ruoyi.equ.service.IEquColRetuDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 设备领用归还明细信息Controller
 * 
 * @author lgq
 * @date 2023-05-16
 */
@RestController
@RequestMapping("/recording/detail")
public class EquColRetuDetailController extends BaseController
{
    @Autowired
    private IEquColRetuDetailService equColRetuDetailService;

    /**
     * 查询设备领用归还明细信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EquColRetuDetail equColRetuDetail)
    {
        startPage();
        List<EquColRetuDetail> list = equColRetuDetailService.selectEquColRetuDetailList(equColRetuDetail);
        return getDataTable(list);
    }

    /**
     * 导出设备领用归还明细信息列表
     */
    @Log(title = "设备领用归还明细信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EquColRetuDetail equColRetuDetail)
    {
        List<EquColRetuDetail> list = equColRetuDetailService.selectEquColRetuDetailList(equColRetuDetail);
        ExcelUtil<EquColRetuDetail> util = new ExcelUtil<EquColRetuDetail>(EquColRetuDetail.class);
        return util.exportExcel(list, "detail");
    }

    /**
     * 获取设备领用归还明细信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(equColRetuDetailService.selectEquColRetuDetailById(id));
    }

    /**
     * 新增设备领用归还明细信息
     */
    @Log(title = "设备领用归还明细信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquColRetuDetail equColRetuDetail)
    {
        return toAjax(equColRetuDetailService.insertEquColRetuDetail(equColRetuDetail));
    }

    /**
     * 修改设备领用归还明细信息
     */
    @Log(title = "设备领用归还明细信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EquColRetuDetail equColRetuDetail)
    {
        return toAjax(equColRetuDetailService.updateEquColRetuDetail(equColRetuDetail));
    }

    /**
     * 删除设备领用归还明细信息
     */
    @Log(title = "设备领用归还明细信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(equColRetuDetailService.deleteEquColRetuDetailByIds(ids));
    }
}
